package com.gzyct.m.api.common.intf.req;

import java.util.HashMap;
import java.util.Map;

public class InterfaceRequest {

	public static final String VERSION = "version";
	public static final String SERVICE = "service";
	public static final String CHANNEL_CODE = "channel_code";
	public static final String USER_ID = "user_id";
	public static final String TIMESTAMP = "timestamp";
	public static final String CHARSET = "charset";
	public static final String SIGN_TYPE = "sign_type";
	public static final String SIGN = "sign";

	public static final String[] NON_BIZ_KEYS = { CHARSET, VERSION, SERVICE, CHANNEL_CODE, USER_ID,
			TIMESTAMP, SIGN_TYPE, SIGN };

	private String version;

	private String service;

	private String channel_code;

	private String user_id;

	private String timestamp;

	private String charset;

	private String sign_type;

	private String sign;

	private String requestBody;

	private ProtocolType protocolType;

	private Map<String, String> bizParam = new HashMap<String, String>();

	private Map<String, String> requestParam = new HashMap<String, String>();

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getService() {
		return service;
	}

	public void setService(String service) {
		this.service = service;
	}

	public String getChannel_code() {
		return channel_code;
	}

	public void setChannel_code(String channel_code) {
		this.channel_code = channel_code;
	}

	public String getUser_id() {
		return user_id;
	}

	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}

	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	public String getCharset() {
		return charset;
	}

	public void setCharset(String charset) {
		this.charset = charset;
	}

	public String getSign_type() {
		return sign_type;
	}

	public void setSign_type(String sign_type) {
		this.sign_type = sign_type;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getRequestBody() {
		return requestBody;
	}

	public void setRequestBody(String requestBody) {
		this.requestBody = requestBody;
	}

	public ProtocolType getProtocolType() {
		return protocolType;
	}

	public void setProtocolType(ProtocolType protocolType) {
		this.protocolType = protocolType;
	}

	public Map<String, String> getBizParam() {
		return bizParam;
	}

	public void setBizParam(Map<String, String> bizParam) {
		this.bizParam = bizParam;
	}

	public Map<String, String> getRequestParam() {
		return requestParam;
	}

	public void setRequestParam(Map<String, String> requestParam) {
		this.requestParam = requestParam;
	}

	private static String buildToString(InterfaceRequest ir) {
		ProtocolType protocolType = ir.getProtocolType();
		String toString = "";
		switch (protocolType) {
			case HTTP_JSON:
				toString = ir.getRequestBody();
				break;
			default:
				toString = ir.getRequestParam().toString();
				break;
		}
		return toString;
	}

	@Override
	public String toString() {
		return InterfaceRequest.buildToString(this);
	}

}
